package com.itheima.project.web;

import com.itheima.project.basic.ResponseWrap;
import com.itheima.project.core.enums.trade.PayChannelEnum;
import com.itheima.project.face.TradingFace;
import com.itheima.project.utils.ResponseWrapBuild;
import com.itheima.project.vo.trade.TradingVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName TradingFace.java
 * @Description 交易Face接口
 */
@RequestMapping("trade")
@RestController
@Api(tags = "交易controller")
public class TradingController {

    @Autowired
    TradingFace tradingFace;

    /***
     * @description 按交易状态查询交易单
     * @param tradingState
     * @return
     */
    @GetMapping("{tradingState}")
    @ApiOperation(value = "查询交易单",notes = "查询交易单")
    @ApiImplicitParam(paramType = "path",name = "tradingState",value = "交易状态",required = true,dataType = "String")
    ResponseWrap<List<TradingVo>> findTradingByTradingState(@PathVariable("tradingState") String tradingState){
        List<TradingVo> tradingVos = tradingFace.findTradingByTradingState(tradingState);
        return ResponseWrapBuild.build(PayChannelEnum.SUCCEED,tradingVos);
    }
}
